import time
from selenium import webdriver
from selenium.webdriver import ActionChains

# 打开浏览驱动器
driver = webdriver.Chrome()
driver.implicitly_wait(3)

# 将浏览器最大化
driver.maximize_window()
# 访问兔展工作台
driver.get('https://www.rabbitpre.com/')

# 查找登录按钮并点击按钮
signin_button = driver.find_element_by_css_selector('#g-j-signin-btn')
signin_button.click()
time.sleep(3)
# 定位元素
login_iframe = driver.find_element_by_css_selector('#sso')
driver.switch_to.frame(login_iframe)

account_button = driver.find_element_by_css_selector('span[data-type="tuzhan"]')
account_button.click()

username = driver.find_element_by_css_selector('[placeholder="请输入你的登录账户"]')
username.send_keys('****')

password = driver.find_element_by_css_selector('[placeholder="请输入密码"]')
password.send_keys('****')

login_button = driver.find_element_by_css_selector('button.g-btn.login-btn.do-btn')
login_button.click()
time.sleep(2)
create = driver.find_element_by_css_selector('a.navbar-addTemplate-btn')
create.click()
# 切换至新窗口
driver.switch_to.window(driver.window_handles[-1])
time.sleep(2)
driver.find_element_by_css_selector('div.create-icon').click()
time.sleep(2)
# 移动到互动按钮
ActionChains(driver).move_to_element(driver.find_element_by_css_selector('span.icon.e-icon.icon-interact')).perform()
time.sleep(2)
driver.find_element_by_css_selector('span.item-icon.e-icon.icon-anniu').click()
time.sleep(2)
driver.find_element_by_css_selector('button.g-btn.primary.icon-btn.publish').click()
# 关闭浏览器
driver.quit()